<?php

require_once(ABSPATH . 'portal/main.php');

class Article extends Main {
	
	function Article() {
		parent::Main();
		$this->database();
	}

	function index() {
		$this->lib('pagination');
		$total = $this->db->count('article');
		$config = array(
			'total_row' => $total,
			'page_size' => 15
		);
		$this->pagination->init( $config );
		$article_list = $this->db->find('select * from article order by created desc limit ' 
			. $this->pagination->start_row . ',' . $this->pagination->page_size);
			
		$data = array(
			'article_list' => $article_list
		);
		$this->my_view('portal/article_list', $data);
	}
	
	function show($id) {
		$article = $this->db->find_by_id('article', $id);
		$data = array(
			'article'=>$article
		);
		$this->my_view('portal/article', $data);
	}
}

?>
